# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: David Runge <dvzrv@archlinux.org>

pkgname=libgit2-glib
pkgver=0.99.0.1
pkgrel=6
pkgdesc="GLib wrapper for libgit2"
url="https://wiki.gnome.org/Projects/Libgit2-glib"
license=('LGPL2.1')
arch=('x86_64')
depends=('glibc')
makedepends=('gobject-introspection' 'glib2' 'libgit2' 'gtk-doc' 'meson'
'python-gobject' 'vala' 'git')
_commit=9ee6d9a7317d367e99bbba7c4601205e003173e3  # tags/v0.99.0.1^0
source=("git+https://gitlab.gnome.org/GNOME/libgit2-glib.git#commit=$_commit"
        build.diff)
sha256sums=('SKIP'
            '494fb1cdba3b140c0f810d861cb210b5eec9b308dc8da5d9bb2c0088dd0893f6')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgname

  # build fixes
  git apply -3 ../build.diff
}

build() {
  arch-meson $pkgname build -D gtk_doc=true
  ninja -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  depends+=('libgio-2.0.so' 'libgit2.so' 'libglib-2.0.so' 'libgobject-2.0.so')
  provides+=('libgit2-glib-1.0.so')

  DESTDIR="$pkgdir" meson install -C build

  # strip $pkgdir from embedded paths:
  python -m compileall -d "/usr/lib" "$pkgdir/usr/lib"
  python -O -m compileall -d "/usr/lib" "$pkgdir/usr/lib"

  install -vDm 644 $pkgname/{AUTHORS,ChangeLog,NEWS,README} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}
